<template>
  <el-table v-loading="loading" border :data="tableData" show-overflow-tooltip>
    <el-table-column label="报表名称" align="center" prop="reportName" />
    <el-table-column label="生产日期" align="center" prop="taskTimeStart" />
    <el-table-column label="班次" align="center" prop="classesName" />
    <el-table-column label="工段" align="center" prop="workshopName" />
    <el-table-column label="产线" align="center" prop="productLineName" />
    <el-table-column label="工艺段" align="center" prop="sectionName" />
    <el-table-column
      label="操作"
      align="center"
      width="120"
      fixed="right"
      class-name="small-padding fixed-width"
    >
      <template #default="scope">
        <el-button
          link
          type="primary"
          icon="Edit"
          v-hasPermi="['produce:feeding:edit']"
          v-if="scope.row.status == 1"
          @click="handleUpdate(scope.row)"
        >
          审核
        </el-button>
      </template>
    </el-table-column>
  </el-table>

  <pagination
    v-show="total > 0"
    :total="total"
    v-model:page="queryParams.pageNum"
    v-model:limit="queryParams.pageSize"
    @pagination="getList"
  />
</template>

<script setup name="TodoTable">
import { toRefs, ref, reactive, getCurrentInstance } from "vue";
import { listTaskRecordReport } from "@/api/productionMgt/taskReport";
import addData from "./../../productionMgt/taskReport/data.vue";
const { proxy } = getCurrentInstance();
const props = defineProps({
  api: {
    type: Function,
    default: null,
  },
  initParams: {
    type: Object,
    default: () => {},
  },
  params: {
    type: String,
    default:'',
  },
});
const loading = ref(true);
const tableData = ref([]);
const total = ref(0);
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    queryToDoTask:true,
    status: undefined,
  },
});
const { queryParams, form } = toRefs(data);

/** 查询字典类型列表 */
function getList() {
  loading.value = true;
  let newForm = JSON.parse(JSON.stringify(queryParams.value));
  if(props.params){
    console.log(props.params);
    newForm.workshopCode = props.params.split('/')[0] || '';
    newForm.lineCode = props.params.split('/')[1] || '';
    newForm.sectionCode = props.params.split('/')[2] || '';
  }
  listTaskRecordReport(proxy.addDateRange(newForm)).then((response) => {
    tableData.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
// 审核
function handleUpdate(row) {
  proxy.subPage(addData, { title: "报表详情", data: row, type: "view" }, () => {
    getList();
  });
}
getList();
</script>

<style lang="scss" scoped></style>
